package com.hbusa.service.impl;

import cn.hutool.db.Entity;
import cn.hutool.db.PageResult;
import com.hbusa.dao.impl.NovelsDaoImpl;
import com.hbusa.dto.TbNovels;
import com.hbusa.service.NovelsService;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Map;

/**
 * @author Sandwich
 * @version 1.0
 * @date 2021/12/27-0:16
 */
public class NovelsServiceImpl implements NovelsService {

    NovelsDaoImpl novelsDao = new NovelsDaoImpl();

    /**
     * 增
     * @param novels
     * @return
     */
    @Override
    public boolean save(TbNovels novels) {
        return novelsDao.save(novels);
    }

    /**
     * 修改
     * @param novels 小说类
     * @return 返回是否修改成功
     */
    @Override
    public boolean modify(TbNovels novels) {
        boolean modify = false;
        try {
            modify = novelsDao.modify(novels);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return modify;
    }

    /**
     * 通过id删除小说
     * @param novelId 数据库里面小说id
     * @return
     */
    @Override
    public boolean removeById(int novelId) {
        return novelsDao.removeById(novelId);
    }

    @Override
    public ArrayList<TbNovels> findAll() {
        return novelsDao.findAll();
    }

    @Override
    public ArrayList<TbNovels> findByString(String novelName) {
        return novelsDao.findByString(novelName);
    }

    @Override
    public TbNovels findNovelById(int novelId) throws SQLException {
        return novelsDao.findNovelById(novelId);
    }

    @Override
    public PageResult<Entity> queryByPage(int pageindex, int pagesize, Map<String, Object> searchMap) {
        return null;
    }
}
